package model;

import xl.XLException;
import expr.ExprParser;

public class CellFactory {
	public Cell build(String s){
		ExprParser parser = new ExprParser();
		if (!s.isEmpty()) {
			if (s.charAt(0) == '#') {
				return new TextCell(s);
			} else {
				try {
					return new ExprCell(parser.build(s));
				} catch (Exception e) {
					throw new XLException("Build error");
				}
			}
		}
		return null;
	}
}
